var publishAppInfo = {
		
	load : function () {
		Ext.QuickTips.init();
		this.eventRegister();
		
	},
	succ : function()
	{
		window.location.href='publishMAppList.php';
	},
	eventRegister : function () {
		Ext.get("confirm").on('click',this.confrim);  //確認,新增使用者		
	},
	
	
	
	confrim : function () {	   	 
	    
	    
	    waitShow("新增中...");
	    Ext.Ajax.request({
	    	method : "POST",
	     	form : "appInfoForm",
	    	callback : function (options, se, rsp) {
	    		waitHide();
	    		var obj = rsp.responseText.toJSON();  
	    		if (obj.result =="1") {
	    			alert("新增成功!");
	    			publishAppInfo.succ();
	    		} else{
	    			alert(obj.msg);
	    		}
	    	}
	    	
	    });
 	}  
};

Ext.onReady(function (){
	publishAppInfo.load();
});
$(document).ready(function(){
    $.ajax({
        url: '/ad/sys/com/control/AdCategorService.php',
        cache: false,
        dataType: 'json',
            type:'get',
        data: { action: 'getAll'
            },
        error: function(xhr) {
          alert('Ajax request 發生錯誤');
        },
        success: function(response) {
                  var arrays=(response);
                  var html='';
                  $(arrays).each(function(index){
                      if(index%5==0&&index!=0)
	                       html+="<br/>";
                      html+='  <input name="adcategorId" type="radio" value="'+this.Value+'" />'+this.Text+'&nbsp;';
                      });
                  $('#adCategorSpan').html(html);
                  init();
         
        }
    });
});

function init()
{
	
    $("input:[name=adcategorId]:radio").each(function(index){
    	if(index==0)
		{
	        this.checked=true;
	        return;
		}
        
    });
    $("input:[name=appType]:radio").each(function(index){
       	if(index==0)
		{
            this.checked=true;
            return;
        }
    });

}


